package com.logic.landseaserver.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.logic.common.exception.BusinessException;
import com.logic.common.security.SecurityUtils;
import com.logic.common.util.QueryUtil;
import com.logic.landseaserver.domain.AuditLog;
import com.logic.landseaserver.persistence.read.AuditLogReadMapper;
import com.logic.landseaserver.persistence.write.AuditLogWriteMapper;
import com.logic.landseaserver.service.IAuditLogService;

public class AuditLogServiceImpl implements IAuditLogService {


	@Autowired
	private AuditLogReadMapper auditLogReadMapper;

	@Autowired
	private AuditLogWriteMapper auditLogWriteMapper;

	@Override
	public void delete(String arg0) throws BusinessException {
		// TODO Auto-generated method stub

	}

	@Override
	public Object get(Integer arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return auditLogReadMapper.selectByPrimaryKey(arg0);
	}

	@Override
	public int insert(Object arg0) throws BusinessException {
		Integer id = -1;
		Boolean pass = this.validateForInsert(arg0);
		if (pass) {
			AuditLog auditLog = (AuditLog) arg0;
			auditLog.updateCommonInfo(SecurityUtils.getCurrentLogin().getUserId());
			auditLogWriteMapper.insertSelective(auditLog);
			id = auditLog.getId();
		}
		return id;
	}

	@Override
	public List<?> query(QueryUtil arg0) {
		// TODO Auto-generated method stub
		return auditLogReadMapper.getList(arg0);
	}

	@Override
	public void update(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub

	}

	@Override
	public Boolean validate(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean validateForDelete(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean validateForInsert(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public Boolean validateForUpdate(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

}
